use "UMASS_MODULE_2010.DTA", clear

* Generate indicator for conditions where Williams was a Democrat/Republican

gen demcand=1 if UMA308b~=. | UMA308d~=. | UMA308f~=. | UMA308h~=.
replace demcand=0 if UMA308a~=. | UMA308c~=. | UMA308e~=. | UMA308g~=.

* Generate indicator for whether Williams appealed to Latinos
gen latinos=1 if UMA308a~=. | UMA308b~=.
replace latinos=0 if latinos==.

* Generate indicator for whether Williams appealed to Unions
gen unions=1 if UMA308c~=. | UMA308d~=.
replace unions=0 if unions==.

* Generate indicator for whether Williams appealed to Born Agains
gen religious=1 if UMA308e~=. | UMA308f~=.
replace religious=0 if religious==.

* Generate the dependent variable
gen eval=UMA308a
replace eval=UMA308b if eval==.
replace eval=UMA308c if eval==.
replace eval=UMA308d if eval==.
replace eval=UMA308e if eval==.
replace eval=UMA308f if eval==.
replace eval=UMA308g if eval==.
replace eval=UMA308h if eval==.

* Generate an indicator for whether the respondent answered "Not sure"
gen evaldk=1 if eval==997
replace evaldk=0 if eval<997

* Recode "not sure" responses to missing for the DV
recode eval 997=.

* Create indicator for whether R is Hispanic
ren V290 hispanic
recode hispanic 2=0
replace hispanic=1 if V211==3

*Create indicator for whether R is Born Again
recode V215 2=0
ren V215 bornagain

* Create indictor for whether R is in a Union or in a Union Household
gen unionhh=1 if V264==1 | V265==1
replace unionhh=0 if unionhh==.

* Set data for using sampling weights
svyset [pw=V102]


*** Produces estimates for top portion of Figure 3 ***

* For Democratic Candidate (left side of Figure)
svy: reg eval latinos if demcand==1 & hispanic==1 & unions~=1 & religious~=1
svy: reg eval unions if demcand==1 & unionhh==1 & latinos~=1 & religious~=1
svy: reg eval religious if demcand==1 & bornagain==1 & unions~=1 & latinos~=1

* For Republican Candidate (right side of Figure)
svy: reg eval latinos if demcand==0 & hispanic==1 & unions~=1 & religious~=1
svy: reg eval unions if demcand==0 & unionhh==1 & latinos~=1 & religious~=1
svy: reg eval religious if demcand==0 & bornagain==1 & unions~=1 & latinos~=1

*** Produces estimates for top portion of Figure 4 ***

* For Democratic Candidate (left side of Figure)
svy: reg eval latinos if demcand==1 & hispanic==0 & unions~=1 & religious~=1
svy: reg eval unions if demcand==1 & unionhh==0 & latinos~=1 & religious~=1
svy: reg eval religious if demcand==1 & bornagain==0 & unions~=1 & latinos~=1

* For Republican Candidate (right side of Figure)
svy: reg eval latinos if demcand==0 & hispanic==0 & unions~=1 & religious~=1
svy: reg eval unions if demcand==0 & unionhh==0 & latinos~=1 & religious~=1
svy: reg eval religious if demcand==0 & bornagain==0 & unions~=1 & latinos~=1

